"""
This example shows how to create delay and sum beamformers
"""

from __future__ import division, print_function

import matplotlib.pyplot as plt
import numpy as np

import pyroomacoustics as pra

# Create a 4 by 6 metres anechoic room
room = pra.AnechoicRoom(dim=2)

# Add a source somewhere in the room
room.add_source([2.5, 4.5])

# Create a linear array beamformer with 4 microphones
# with angle 0 degrees and inter mic distance 10 cm
R = pra.linear_2D_array([2, 1.5], 4, 0, 0.04)
room.add_microphone_array(pra.Beamformer(R, room.fs))

# Now compute the delay and sum weights for the beamformer
room.mic_array.rake_delay_and_sum_weights(room.sources[0][:1])

# plot the room and resulting beamformer
room.plot(freq=[1000, 2000, 4000, 8000])
plt.show()
